<!--
 * @Description: 
 * @Author: Leequik
 * @Date: 2025-06-15 15:04:32
 * @LastEditTime: 2025-07-07 10:32:30
 * @LastEditors: Leequik
-->
<!--
 自定义事件:实现子传父
 
-->
<template>
    <div class="father">
        <h3>父组件</h3>
        <h4 v-show="toy"> 儿子给的玩具：{{ toy }}</h4>
        <!--给子组件child绑定事件-->
        <Child @send-toy="saveToy" />
    </div>
</template>saveToy
<script lang="js" setup>
    import Child from './Child.vue';
    import { ref } from 'vue';
    
    let toy = ref('');
    
    function saveToy(value){
        console.log('子组件点击');
        toy.value = value;
    }
</script>
<style scoped>
    .father{
        background-color: orange;
        padding: 20px;
        border-radius: 10px;
    }
    button{
        margin: 10px;
    }
</style>